#include <bits/stdc++.h>
using namespace std;

// 生成随机数
mt19937 rnd(time(0));

// 生成[l,r]范围内的随机整数
long long randInt(long long l, long long r) {
    return l + rnd() % (r - l + 1);
}

// 生成一个随机置换表
string genPermutation(bool identity = false) {
    string s = "abcdefghijklmnopqrstuvwxyz";
    if(!identity) {
        shuffle(s.begin(), s.end(), rnd);
    }
    return s;
}

// 生成单个测试数据文件
void genOneTest(int testId, string folder = "data", string prefix = "string") {
    string filename = folder + "\\" + prefix + to_string(testId) + ".in";
    freopen(filename.c_str(), "w", stdout);
    
    // 生成T组数据
    int T = randInt(1, 5);
    cout << T << "\n";
    
    while(T--) {
        long long n;
        // 根据测试点编号决定数据规模和特性
        if(testId <= 4) {
            n = randInt(1, 2);
        } else if(testId <= 8) {
            if(testId <= 6) n = randInt(5, 10);
            else n = randInt(1e8, 1e9);
        } else if(testId <= 10) {
            n = randInt(500, 1000);
        } else if(testId <= 12) {
            n = randInt(50000, 100000);
        } else if(testId <= 16) {
            n = randInt(5000000, 10000000);
        } else {
            n = randInt(500000000, 1000000000);
        }
        
        cout << n << "\n";
        
        // 特殊性质A: 置换表是恒等置换
        if(testId >= 5 && testId <= 8) {
            cout << genPermutation(true) << "\n";
        } else {
            cout << genPermutation() << "\n";
        }
    }
}

int main() {
    // 生成样例数据
    // 样例1：小数据，恒等置换
    string filename = "sample\\string1.in";
    freopen(filename.c_str(), "w", stdout);
    cout << "1\n1\n" << genPermutation(true) << "\n";
    
    // 样例2：小数据，随机置换
    filename = "sample\\string2.in";
    freopen(filename.c_str(), "w", stdout);
    cout << "1\n1\nabcdefghijklmnopqrstuvwzyx\n";
    
    // 样例3：大规模数据
    filename = "sample\\string3.in";
    freopen(filename.c_str(), "w", stdout);
    cout << "1\n1000000000\n" << genPermutation() << "\n";
    
    // 生成测试数据
    for(int i = 1; i <= 20; i++) {
        genOneTest(i);
    }
    
    return 0;
}
